package org.example.commonapi.domain.onlineCode;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

@Data
@Document(collection = "commit_record")
@AllArgsConstructor
@NoArgsConstructor
public class CommitRecord {
    private String id;
    private String submitTime;
    private String username;
    @Field("nike_name")
    private String nikeName;
    private String problemId;
    private String code;
    private String language;
    private String time;
    private String memory;
    @Field("run_time")
    private String runTime;


    public CommitRecord(OjCode ojCode,CodeResultForOJ codeResult) {
        this.username = codeResult.getUsername();
        this.nikeName = codeResult.getNikeName();
        this.code = ojCode.getCode();;
        this.language = ojCode.getLanguage();
        this.time =codeResult.getTime().replace("ms", "");
        this.memory = codeResult.getMemory().replace("kb", "");
        this.runTime = codeResult.getRunTime().replace("ms", "");
        this.problemId=ojCode.getProblemId();
        this.submitTime=codeResult.getSubmitTime();
    }
}
